package com.csx.set;

import com.csx.linkedlist.LinkedList;

import java.util.Set;
import java.util.TreeSet;

public class Solution {
    public int uniqueMorseRepresentations(String[] words) {
        String[] codes = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
        Set<String> set = new TreeSet<>();
        for (String word:words) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < word.length(); i++) {
                builder.append(codes[word.charAt(i) - 'a']);
            }
            System.out.println(builder);
            set.add(builder.toString());
        }
        return set.size();
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        String[] codes = {"gin","gig","zen","msg"};
        int i = solution.uniqueMorseRepresentations(codes);
        System.out.println(i);
    }
  }
